package com.zp.io;

import java.io.RandomAccessFile;

public class RandomAccessFile1 {
	public static void main(String[] args) throws Exception {
		Person person = new Person(1,"zhangpeng",12.4);
		RandomAccessFile raf = new RandomAccessFile("D:/lisi/test.txt","rw");
		
		person.write(raf);
		
		Person person2 = new Person();
		// 让读的位置重回到文件开头:因为写完之后就到数据的最后了
		raf.seek(0); 

		person2.read(raf);

		System.out.println(person2.getId() + ", " + person2.getName() + ", "
				+ person2.getHeight());
	} 
}
